Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move get_file and save_file to ConfigurationManagementMixin #17494

Merged
merged 1 commit into from
May 30, 2018

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented May 29, 2018

In moving, the methods become settings_for_resource_yaml and
add_settings_for_resource_yaml, respectively. The old interfaces are
still left intact temporarily until the UI is changed to use the new
methods.

Also preserved is the special activation that is currently done for
ntp_reload, as introduced in 939524fa, which avoids
repeated activation for every worker, instead preferring to do it once
at the server level.

Replaces #17458
@carbonin Please review
cc @h-kataria

@Fryguy
Copy link
Member Author

Fryguy commented May 29, 2018

@carbonin While I left the yaml interface here in this PR, I'm wondering if instead that should just live in the advanced_settings screen directly, essentially moving the yaml handling code and the password encryption/decryption there. Thoughts?

@Fryguy
Copy link
Member Author

Fryguy commented May 29, 2018

Not changing the YAML.load calls as rubocop wants.

@h-kataria
Copy link
Contributor

@Fryguy tested it with ManageIQ/manageiq-ui-classic#3967, seems to work 👍

@Fryguy Fryguy force-pushed the move_get_file_set_file branch 2 times, most recently from 73e383a to a3ada01 Compare May 29, 2018 20:37
hash =
begin
decrypt_passwords!(YAML.load(contents))
rescue => err
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the previous code, this enumerated both StandardError and Psych::SyntaxError. We had done this in the past because Psych::SyntaxError used to not derive from StandardError, but in Ruby 2.3 and 2.4 that is no longer the case, so we can just catch StandardError like normal. I did this because rubocop rightly complains with Lint/ShadowedException

[1] pry(main)> Psych::SyntaxError < StandardError
=> true
[2] pry(main)> RUBY_VERSION
=> "2.3.3"
[3] pry(main)> Psych::VERSION
=> "2.1.0"

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just the one nit in the comment

#
# As an example, ntp_reload works by telling systemctl to restart
# chronyd. However, if this occurs on every worker, you end up with
# dozens of calls to `systemctl chrony restart` simultaneously.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemctl restart chronyd 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh! (-‸ლ)

@Fryguy Fryguy force-pushed the move_get_file_set_file branch from a3ada01 to f15efd3 Compare May 29, 2018 20:44
@Fryguy
Copy link
Member Author

Fryguy commented May 29, 2018

@carbonin Fixed. Also, I added an extra spec for the different types of YAML failures, and there's a note above about the changes to how it's rescued (not sure you saw those changes in your review)

@Fryguy
Copy link
Member Author

Fryguy commented May 29, 2018

I am not fixing the Style/RescueStandardError. I just disagree with it and am going to open a PR to guides to change the default.

#
# As an example, ntp_reload works by telling systemctl to restart
# chronyd. However, if this occurs on every worker, you end up with
# dozens of calls to `systemctl chronyd restart` simultaneously.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still... it's systemctl restart chronyd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭

In moving, the methods become settings_for_resource_yaml and
add_settings_for_resource_yaml, respectively.  The old interfaces are
still left intact temporarily until the UI is changed to use the new
methods.

Also preserved is the special activation that is currently done for
ntp_reload, as introduced in ManageIQ/manageiq@939524fa, which avoids
repeated activation for every worker, instead preferring to do it once
at the server level.

https://bugzilla.redhat.com/show_bug.cgi?id=1082155
@Fryguy Fryguy force-pushed the move_get_file_set_file branch from f15efd3 to 46fae81 Compare May 29, 2018 22:11
@miq-bot
Copy link
Member

miq-bot commented May 29, 2018

Checked commit Fryguy@46fae81 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 4 offenses detected

lib/vmdb/settings.rb

spec/lib/vmdb/settings_spec.rb

@Fryguy
Copy link
Member Author

Fryguy commented May 29, 2018

@carbonin Done for real now.

Also, thoughts on #17494 (comment) ?

@carbonin
Copy link
Member

While I left the yaml interface here in this PR, I'm wondering if instead that should just live in the advanced_settings screen directly, essentially moving the yaml handling code and the password encryption/decryption there. Thoughts?

I guess it depends on if you want that to be a "supported API" or if that's just a quirk of the way we are displaying things. I'm fine with either, but I think it only makes sense if we admit that saving the whole YAML at once is an exception rather than the norm.

@carbonin carbonin merged commit 1c1b2b2 into ManageIQ:master May 30, 2018
@carbonin carbonin added this to the Sprint 87 Ending Jun 4, 2018 milestone May 30, 2018
@Fryguy Fryguy deleted the move_get_file_set_file branch June 28, 2018 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants